﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace libraryMIS
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new LoginForm());
        }
    }
}


namespace WindowsFormsApplication1
{
    public partial class mainfrom : Form
    {
        public mainfrom()
        {
            InitializeComponent();
        }
        #region 关机按钮实现：鼠标进入 鼠标离开 关闭系统
        private void label2_Click(object sender, EventArgs e)
        {
            pictureboxclose.backcolor = Color.Red
        }

        private void panelrttop_Paint(object sender, PaintEventArgs e)
        {
            //this.Close();
            //this.Dispose();
            //Application.Exit();
            System.Environment.Exit(0);
        }



        private void pictureboxmore_Click(object sender, EventArgs e)
        {

        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {
            //this.Close();
            //this.Dispose();
            //Application.Exit();
            System.Environment.Exit(0);
        }
    }
}




{
     pictureBoxClose.BackColor = Color.Red;

    //this. Close() ;//关闭当前窗口
   //this. Dispose()://释放资源
    //Application.Exit();//消息终止
    System.Environment.Exit (0) ://完全释放
 } 
1个引用
   private void pictureBoxClose_ MouseLeave(ob ject sender， EventArgs e)
  pictureBoxClose.BackColor = Color.White;
}
}
